﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace cds_betadev01.source
{
    class Camera :Obj
    {
        private Matrix Projection;
        private float fovy = 120.0f;
        private float aspecRatio = 1.0f;
        private float near = 1.0f;
        private float far = 100000000.0f;

        
        public Camera()
        {
            fovy = MathHelper.ToRadians(45.0f);
            uploadProjection();
        }
        public Camera(Vector3 ppos, Vector3 ttar, Vector3 uupV, float ffovy, float aaspecRatio, float nnear, float ffar)
        {
            World = Matrix.CreateLookAt(ppos, ttar, uupV);
            setProjection( ffovy,  aaspecRatio,  nnear,  ffar);
            
        }
        public Camera(Vector3 ppos, Vector3 ttar, Vector3 uupV)
        {
            fovy = MathHelper.ToRadians(45.0f);
            World = Matrix.CreateLookAt(ppos, ttar, uupV);
            setProjection(fovy, aspecRatio, near, far);
        }
        //getset
        public Matrix getProjection()
        {
            return Projection;
        }
        public void setProjection(float ffovy, float aaspecRatio, float nnear, float ffar) //a eviter
        {
            fovy = ffovy;
            aspecRatio = aaspecRatio;
            near = nnear;
            far = ffar;
            uploadProjection();
        }
        public void setAspecRatio(float rratio)
        {
            aspecRatio = rratio;
            uploadProjection();

        }
        public void setFovy(float ffovy)
        {
            fovy = ffovy;
            uploadProjection();

        }
        public float getFovy()
        {
            return fovy;
        }
        public void setNear(float nnear)
        {
            near = nnear;
            uploadProjection();

        }
        public void setFar(float ffar)
        {
            far = ffar;
            uploadProjection();

        }
        public void draw(ObjDisplay oobjet)
         {
                oobjet.draw(World, Projection);
         }
       
        public void uploadProjection()
        {
            Projection = Matrix.CreatePerspectiveFieldOfView(fovy, aspecRatio, near, far);
        }
    
    }
}
